#include <stdio.h>
#include <stdlib.h>

//https://www.nowcoder.com/practice/258fe0c567ac493f9b7bc9d3669d158d?tpId=290&tqId=618633&ru=/exam/oj/ta&qru=/ta/beginner-programmers/question-ranking&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D290

typedef struct ARR {
    int n;
    int Arr[0];
}ARR;

int main() {
    int row = 0;
    int col = 0;
    scanf("%d%d", &row, &col);
    ARR *arr = (ARR *) malloc(sizeof(ARR) + row * col * sizeof(int));
    if (!arr) {
        perror("堆区开辟内存失败:");
    }
    arr->n = row * col;
    for (int i = 0; i < arr->n; i++) {
        scanf("%d", arr->Arr + i);
    }
    int max = arr->Arr[0];
    int n = 0;
    for (int i = 1; i < row * col; i++) {
        if (arr->Arr[i] > max) {
            max = arr->Arr[i];
            n = i;
        }
    }
    printf("%d %d", n / col, n % col + 1);
    free(arr);
    arr = NULL;
    return 0;
}